package com.telit.firecommand.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.telit.firecommand.entity.CameraDownloadLog;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;


@Repository
public interface CameraDownloadLogDao {

    int deleteByPrimaryKey(Long id);

    int insert(CameraDownloadLog record);

    int insertSelective(CameraDownloadLog record);

    CameraDownloadLog selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(CameraDownloadLog record);

    int updateByPrimaryKey(CameraDownloadLog record);


    /**
     * 条件查询历史监控视频
     *
     * @param iPage
     * @param cameraName
     * @param startTime
     * @param endTime
     *
     * @return
     */
    IPage<CameraDownloadLog> queryByCondition(IPage<CameraDownloadLog> iPage, @Param("cameraName") String cameraName,
                                              @Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 条件查询历史监控视频 -过滤名称
     *
     * @param names
     * @param iPage
     * @param cameraName
     * @param startTime
     * @param endTime
     *
     * @return
     */
    IPage<CameraDownloadLog> queryByConditionWithNames(@Param("names") List<String> names,
                                                       IPage<CameraDownloadLog> iPage,
                                                       @Param("cameraName") String cameraName,
                                                       @Param("startTime") String startTime,
                                                       @Param("endTime") String endTime);

    /**
     * 根据下载人和时间查询
     *
     * @param cameraName
     * @param person
     * @param startTime
     * @param endTime
     *
     * @return
     */
    CameraDownloadLog queryByPersonAndTime(@Param("cameraName") String cameraName, @Param("person") String person,
                                           @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    /**
     * 查询是否已经下载过
     *
     * @param cameraName
     * @param downloadPerson
     * @param startTime
     * @param endTime
     *
     * @return
     */
    Long queryHasDownLoad(@Param("cameraName") String cameraName, @Param("downloadPerson") String downloadPerson,
                          @Param("startTime") Date startTime, @Param("endTime") Date endTime);

}